package com.realone.packman.codec.encoder;

import com.realone.packman.codec.encoder.vo.BmsEncoderDataVo07;

import java.nio.ByteBuffer;

/**
 * 设置BMS充电参数 编码
 *
 * @author hugx
 * @create 2018-09-14 15:57
 */
public class BmsEncoder07 extends BmsEncoder<BmsEncoderDataVo07> {

    @Override
    protected byte[] encoderData(BmsEncoderDataVo07 bmsEncoderDataVo07) {
        ByteBuffer bb = ByteBuffer.allocate(16);
        bb.putShort((short) (bmsEncoderDataVo07.getOverVoltage() * 1000));
        bb.putShort((short) (bmsEncoderDataVo07.getOverVoltageRestore() * 1000));
        bb.putShort((short) (bmsEncoderDataVo07.getChargeOverCurrent() * 10));
        bb.putShort((short) (bmsEncoderDataVo07.getChargeUnbalanceCurrent() * 10));
        bb.putShort((short) (bmsEncoderDataVo07.getChargeUnbalanceVoltage() * 1000));
        bb.put(bmsEncoderDataVo07.getChargeHighTemperature());
        bb.put(bmsEncoderDataVo07.getChargeLowTemperature());
        bb.putShort((short) (bmsEncoderDataVo07.getChargeBalanceVoltage() * 1000));
        bb.putShort((short) (bmsEncoderDataVo07.getChargeBalanceendVoltage() * 1000));

        return bb.array();
    }
}
